<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%  
String path = request.getContextPath();  
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";  
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>${systemName }</title>
    <link rel="shortcut icon" href="favicon.ico"> 
    <link href="<%=basePath %>resources/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="<%=basePath %>resources/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="<%=basePath %>resources/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="<%=basePath %>resources/css/animate.min.css" rel="stylesheet">
    <link href="<%=basePath %>resources/css/style.min.css?v=4.1.0" rel="stylesheet">
    <link href="<%=basePath %>resources/css/plugins/toastr/toastr.min.css" rel="stylesheet">
</head>
<body class="gray-bg">
    <div class="wrapper wrapper-content">
        <div class="row">
            <div class="col-sm-3">
                <div class="ibox float-e-margins">
                    <div class="ibox-content mailbox-content">
                        <div class="file-manager">
                            <%--
                            <a class="btn btn-block btn-primary compose-mail" href="mail_compose.html">添加ukw</a>
                             --%>
                            <div class="space-25"></div>
                            <h5>身体部位</h5>
                            <ul class="folder-list m-b-md" style="padding: 0">
                                <c:forEach items="${diseaseCategoryDictList }" var="i" >
                                <li>
                                    <a href="<%=basePath %>system/disease/category/manager?id=${i.id}"> <i class="fa fa-certificate"></i> ${i.name } </a>
                                </li>
                                </c:forEach>
                            </ul>
                            <%--
                            <h5 class="tag-title">标签</h5>
                            <ul class="tag-list" style="padding: 0">
                                <li><a href="mail_compose.html"><i class="fa fa-tag"></i> 朋友</a>
                                </li>
                                <li><a href="mail_compose.html"><i class="fa fa-tag"></i> 工作</a>
                                </li>
                                <li><a href="mail_compose.html"><i class="fa fa-tag"></i> 家庭</a>
                                </li>
                                <li><a href="mail_compose.html"><i class="fa fa-tag"></i> 孩子</a>
                                </li>
                                <li><a href="mail_compose.html"><i class="fa fa-tag"></i> 假期</a>
                                </li>
                                <li><a href="mail_compose.html"><i class="fa fa-tag"></i> 音乐</a>
                                </li>
                                <li><a href="mail_compose.html"><i class="fa fa-tag"></i> 照片</a>
                                </li>
                                <li><a href="mail_compose.html"><i class="fa fa-tag"></i> 电影</a>
                                </li>
                            </ul>
                            --%>
                            <div class="clearfix"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-sm-9 animated fadeInRight">
                <div class="mail-box-header">
                	<%--
                    <form method="get" action="index.html" class="pull-right mail-search">
                        
                        <div class="input-group">
                            <input type="text" class="form-control input-sm" name="search" placeholder="搜索邮件标题，正文等">
                            <div class="input-group-btn">
                                <button type="submit" class="btn btn-sm btn-primary">
                                    搜索
                                </button>
                            </div>
                        </div>
                    </form>
                    --%>
                    
                    <div class="mail-tools tooltip-demo m-t-md">
                        <div class="btn-group pull-right">
                            <%--
                            <button class="btn btn-white btn-sm"><i class="fa fa-arrow-left"></i>
                            </button>
                            <button class="btn btn-white btn-sm"><i class="fa fa-arrow-right"></i>
                            </button>
                             --%>
                            <c:if test="${diseaseCategoryDict.name != null }">
                            <input class="input-sm add_disease_category_text" type="text" value="" placeholder="请输入症状名称" >
                            <a class="btn btn-primary btn-sm" href="javascript:void(0);" onclick="addDiseaseCategory();">添加症状</a>
                            </c:if>
                        </div>
                        <h2>${diseaseCategoryDict.name } </h2>
                         <%--
                        <button class="btn btn-white btn-sm" data-toggle="tooltip" data-placement="left" title="刷新邮件列表"><i class="fa fa-refresh"></i> 刷新</button>
                        <button class="btn btn-white btn-sm" data-toggle="tooltip" data-placement="top" title="标为已读"><i class="fa fa-eye"></i>
                        </button>
                        <button class="btn btn-white btn-sm" data-toggle="tooltip" data-placement="top" title="标为重要"><i class="fa fa-exclamation"></i>
                        </button>
                        <button class="btn btn-white btn-sm" data-toggle="tooltip" data-placement="top" title="标为垃圾邮件"><i class="fa fa-trash-o"></i>
                        </button>
                         --%>
                    </div>
                </div>
                <div class="mail-box">
                    <table class="table table-hover table-mail">
                    	<thead>
                    		<tr>
                    			<th>名称</th>
                    			<th>排序序号</th>
                    			<th>保存修改</th>
                    			<th>删除</th>
                    		</tr>
                    	</thead>
                        <tbody>
                        	<c:forEach items="${subDiseaseCategoryDict }" var="i">
                        	<tr class="unread">
                                <td class=""><input type="text" value="${i.name }" id="name_${i.id }"></td>
                                <td class=""><input type="text" value="${i.seq }" id="seq_${i.id }"></td>
                                <td class=""><button type="button" class="btn btn-primary btn-xs" onclick="updateDiseaseCategory(${i.id });">更新</button></td>
                                <td class=""><button type="button" class="btn btn-outline btn-danger btn-xs" onclick="deleteDiseaseCategory(${i.id });">删除</button></td>
                            </tr>
                        	</c:forEach>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
    <script src="<%=basePath %>resources/js/jquery.min.js?v=2.1.4"></script>
    <script src="<%=basePath %>resources/js/bootstrap.min.js?v=3.3.6"></script>
    <script src="<%=basePath %>resources/js/content.min.js?v=1.0.0"></script>
    <script src="<%=basePath %>resources/js/plugins/iCheck/icheck.min.js"></script>
    <script src="<%=basePath %>resources/js/plugins/toastr/toastr.min.js"></script>
    <script>
        $(document).ready(function(){$(".i-checks").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green",})});
        var parId = "${diseaseCategoryDict.id}";
        function addDiseaseCategory(){
        	toastr.options = {
  			  "closeButton": true,
  			  "debug": false,
  			  "progressBar": true,
  			  "positionClass": "toast-top-center",
  			  "onclick": null,
  			  "showDuration": "400",
  			  "hideDuration": "1000",
  			  "timeOut": "7000",
  			  "extendedTimeOut": "1000",
  			  "showEasing": "swing",
  			  "hideEasing": "linear",
  			  "showMethod": "fadeIn",
  			  "hideMethod": "fadeOut"
  			};
        	var t = $(".add_disease_category_text").val();
        	if(t==''){
        		toastr.warning("疾病名称不能为空");
        		return false;
        	}
       		$.post("<%=basePath%>system/disease/category/merge",{name:t,parentId:parId},function(data){
           		toastr.clear();
           		if(data.status == 0){
           			//toastr.success("添加成功");
           			alert("添加成功");
           			window.location.reload();
           		}else{
           			toastr.error(data.message);
           		}
           	});
        }
        function deleteDiseaseCategory(id){
        	if(confirm("确定要删除该症状吗?")){
	        	$.post("<%=basePath %>system/disease/category/delete",{id:id},function(data){
	        		if(data.status == 0){
	        			//toastr.success("添加成功");
	        			alert("删除成功");
	        			window.location.reload();
	        		}else{
	        			toastr.error(data.message);
	        		}
	        	});
        	}
        }
        
        function updateDiseaseCategory(id){
        	toastr.options = {
  			  "closeButton": true,
  			  "debug": false,
  			  "progressBar": true,
  			  "positionClass": "toast-top-center",
  			  "onclick": null,
  			  "showDuration": "400",
  			  "hideDuration": "1000",
  			  "timeOut": "7000",
  			  "extendedTimeOut": "1000",
  			  "showEasing": "swing",
  			  "hideEasing": "linear",
  			  "showMethod": "fadeIn",
  			  "hideMethod": "fadeOut"
  			};
        	var n = $("#name_"+id).val();
        	var s = $("#seq_"+id).val();
        	if(confirm("确定要更新该症状吗?")){
        		$.post("<%=basePath%>system/disease/category/merge",{name:n,parentId:parId,seq:s,id:id},function(data){
               		toastr.clear();
               		if(data.status == 0){
               			//toastr.success("添加成功");
               			alert("更新成功");
               			window.location.reload();
               		}else{
               			toastr.error(data.message);
               		}
               	});
        	}
        }
        
    </script>
</body>

</html>
